/**
 * 
 */
package com.alessandrodonato.elledia.model;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * @author Alessandro Donato
 *
 * 21/set/2013
 */

/*
@Entity annotation is used to declare the POJO as persistent entity.
@Table annotation is used to map the POJO class to the table. In our case it is 'certificato' table in database.
@Id represents the identifier property.
@GeneratedValue declares that the identifier value will be generated by the database automatically. 
@Column is used to map the property to the column of the table.
*/

@Entity
@Table	(	
					name = "clienti", 
					catalog = "elledia", 
					uniqueConstraints = {
							@UniqueConstraint(columnNames = "ID")
					}
				)
public class Cliente {

	private int id;
	
	private String ragioneSociale;

	@Id
	@GeneratedValue (strategy = IDENTITY)
	@Column (name = "id",unique = true, nullable = false)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getRagioneSociale() {
		return ragioneSociale;
	}

	@Column (name = "ragione_sociale",unique = true, nullable = false, length=255)
	public void setRagioneSociale(String ragioneSociale) {
		this.ragioneSociale = ragioneSociale;
	}
	
	@Override
	public String toString () {
		return "Cliente: id = " + this.id + " - " + this.ragioneSociale;
	}
}
